package org.kalai.unifypay.servlet;

import java.io.IOException;

import javax.websocket.OnClose;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;

import org.kalai.unifypay.SessionManager;

@ServerEndpoint(value = "/TransactionWebsocket/{tranxSN}")
public class TransactionWebsocket {
	@OnOpen
	public void onOpen(Session session, @PathParam("tranxSN") String tranxSN) throws InterruptedException, IOException{
		SessionManager.getInstance().addSession(tranxSN, session);
	}
	
	@OnClose
	public void onClose(Session session, @PathParam("tranxSN") String tranxSN) {
		SessionManager.getInstance().removeSession(tranxSN);
	}
}
